import { IncomingMessage, ServerResponse } from 'http'
import { UrlWithParsedQuery } from 'url'
import { listHandler } from './api/list'

// 集中管理所有的mock路由
export const mockRoutes = [
  {
    url: '/api/list',
    method: 'GET',
    handler: (
      req: IncomingMessage,
      res: ServerResponse<IncomingMessage>,
      url: {
        parse: (url: string, parseQueryString: boolean) => UrlWithParsedQuery
      }
    ) => {
      res.setHeader('Content-Type', 'application/json')
      return listHandler(req, res, url)
    }
  }
]
